package com.TheyChat.service.config.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum StatusEnum implements BaseEnum {

    /**
     * 有效
     */
    VALID(1, "有效"),
    /**
     * 无效
     */
    INVALID(0, "无效"),
    /**
     * 已删除
     */
    DELETED(-1, "已删除");


    @EnumValue
    private final Integer value;
    @Getter
    private final String desc;

    /**
     * 序列化
     *
     * @return 不允许返回 null
     */
    @Override
    public Integer getValue() {
        return this.value;
    }

    @JsonCreator
    public static StatusEnum create(Integer value) throws Exception {
        for (StatusEnum item : StatusEnum.values()) {
            if (item.value.equals(value)) {
                return item;
            }
        }
        throw new Exception("Incorrect enum value for StatusEnum: " + value);
    }

}
